import * as XLSX from "xlsx"
export function readExcel(file) {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.onload = (ev) => {
      try {
        const data = ev.target.result;
        const workBook = XLSX.read(data, {
          type: "binary",
        });
        console.log(workBook);
        let length = workBook.SheetNames.length;
        const wxName = [];
        const ws = [];
        for (let i = 0; i < length; i++) {
          wxName.push(workBook.SheetNames[i]);
          ws.push(XLSX.utils.sheet_to_json(workBook.Sheets[wxName[i]], { header: 1 }));
        }
        console.log(ws);
        resolve({ wxname, ws });
      } catch (e) {
        reject(e);
      }
    };
    reader.readAsBinaryString(file.raw);
  })
}//https://blog.csdn.net/langwang_100/article/details/134597236?spm=1001.2101.3001.6650.3&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7Ebaidujs_baidulandingword%7ECtr-3-134597236-blog-144502497.235%5Ev43%5Epc_blog_bottom_relevance_base7&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7Ebaidujs_baidulandingword%7ECtr-3-134597236-blog-144502497.235%5Ev43%5Epc_blog_bottom_relevance_base7&utm_relevant_index=6